package com.hsylient.demo04;

import lombok.SneakyThrows;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class TestSelect {

    @SuppressWarnings("uncheck")
    @SneakyThrows
    public static void main(String[] args) {
        Connection connection = JdbcUtil.getConnection();
        String sql = "select * from test.user where id = ?";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setInt(1, 13);
        ResultSet resultSet = preparedStatement.executeQuery();
        while (resultSet.next()) {
            String string = resultSet.getString("name");
            System.out.println(string);
        }
        JdbcUtil.closeResource(connection, preparedStatement, resultSet);
    }
}
